import { Api } from 'pf-component';
import { BaseApi, ServiceEnum } from '@/constants/api/base-api';
import { MethodTypeEnum } from '@/constants/enum/method-type.enum';

class SystemApi {
  tenantApi: Api = {};
  companyApi: Api = {};
  userApi: Api = {};
  menuApi: Api = {};
  appApi: Api = {};
  dictApi: Api = {};
  metadataApi: Api = {};
  formConfigApi: Api = {};
  fcFormConfigApi: Api = {};
  tableConfigApi: Api = {};
  roleApi: Api = {};
  postApi: Api = {};
  constructor() {
    this.initKm();
  }

  initKm() {
    this.userApi = {
      listByGuest: {
        url: this.getUrl() + '/user/listByGuest',
        method: MethodTypeEnum.POST
      },
      pageByOrg: {
        url: this.getUrl() + '/user/pageByOrg',
        method: MethodTypeEnum.POST
      },
      pageGuest: {
        url: this.getUrl() + '/user/guest/page',
        method: MethodTypeEnum.POST
      },
      registerGuest: {
        url: this.getUrl() + '/user/registerGuest',
        method: MethodTypeEnum.POST
      },
      assign: {
        url: this.getUrl() + '/user/assign',
        method: MethodTypeEnum.POST
      }
    };
    this.menuApi = {
      add: {
        url: this.getUrl() + '/sysMenuInfo/add',
        method: MethodTypeEnum.POST
      },
      addBatch: {
        url: this.getUrl() + '/sysMenuInfo/addBatch',
        method: MethodTypeEnum.POST
      },
      upd: {
        url: this.getUrl() + '/sysMenuInfo/upd',
        method: MethodTypeEnum.POST
      }
    };
    this.postApi = {
      list: {
        url: this.getUrl() + '/sysPostInfo/list',
        method: MethodTypeEnum.GET
      },
      add: {
        url: this.getUrl() + '/sysPostInfo/add',
        method: MethodTypeEnum.POST
      },
      addUser: {
        url: this.getUrl() + '/sysPostInfo/addUser',
        method: MethodTypeEnum.POST
      },
      listUser: {
        url: this.getUrl() + '/sysPostInfo/listUser',
        method: MethodTypeEnum.GET
      }
    };
    this.roleApi = {
      list: {
        url: this.getUrl() + '/sysRoleInfo/list',
        method: MethodTypeEnum.GET
      },
      add: {
        url: this.getUrl() + '/sysRoleInfo/add',
        method: MethodTypeEnum.POST
      },
      addRoleRel: {
        url: this.getUrl() + '/sysRoleInfo/addRoleRel',
        method: MethodTypeEnum.POST
      },
      addRoleAuth: {
        url: this.getUrl() + '/sysRoleInfo/addRoleAuth',
        method: MethodTypeEnum.POST
      },
      listRoleRel: {
        url: this.getUrl() + '/sysRoleInfo/listRoleRel',
        method: MethodTypeEnum.GET
      },
      listRoleAuth: {
        url: this.getUrl() + '/sysRoleInfo/listRoleAuth',
        method: MethodTypeEnum.GET
      }
    };
    this.dictApi = {
      list: {
        url: this.getUrl() + '/sysDictInfo/list',
        method: MethodTypeEnum.GET
      },
      delete: {
        url: this.getUrl() + '/sysDictInfo/delete',
        method: MethodTypeEnum.POST
      },
      update: {
        url: this.getUrl() + '/sysDictInfo/update',
        method: MethodTypeEnum.POST
      }
    };
    this.appApi = {
      listWithMenu: {
        url: this.getUrl() + '/sysAppInfo/selectAppAndMenuList',
        method: MethodTypeEnum.GET
      },
      list: {
        url: this.getUrl() + '/sysAppInfo/selectAppList',
        method: MethodTypeEnum.GET
      },
      listByTenId: {
        url: this.getUrl() + '/sysAppInfo/listByTen',
        method: MethodTypeEnum.GET
      },
      addApp: {
        url: this.getUrl() + '/sysAppInfo/addApp',
        method: MethodTypeEnum.POST
      }
    };
    this.companyApi = {
      comTree: {
        url: this.getUrl() + '/sysCompanyInfo/selectComTree',
        method: MethodTypeEnum.GET
      },
      deptList: {
        url: this.getUrl() + '/sysCompanyInfo/deptList',
        method: MethodTypeEnum.GET
      },
      addCompany: {
        url: this.getUrl() + '/sysCompanyInfo/addCompany',
        method: MethodTypeEnum.POST
      },
      addDept: {
        url: this.getUrl() + '/sysCompanyInfo/addDept',
        method: MethodTypeEnum.POST
      }
    };
    this.tenantApi = {
      list: {
        url: this.getUrl() + '/sysTenantInfo/list',
        method: MethodTypeEnum.GET
      },
      delete: {
        url: this.getUrl() + '/sysTenantInfo/delete',
        method: MethodTypeEnum.POST
      },
      update: {
        url: this.getUrl() + '/sysTenantInfo/update',
        method: MethodTypeEnum.POST
      }
    };
    this.metadataApi = {
      dbNames: {
        url: this.getUrl() + '/metadata/dbNames',
        method: MethodTypeEnum.GET
      },
      getTableNamesByDb: {
        url: this.getUrl() + '/metadata/getTableNamesByDb',
        method: MethodTypeEnum.GET
      },
      getTableNamesByDbAndTb: {
        url: this.getUrl() + '/metadata/getTableNamesByDbAndTb',
        method: MethodTypeEnum.GET
      }
    };
    this.formConfigApi = {
      list: {
        url: this.getUrl() + '/sysFormInfo/list',
        method: MethodTypeEnum.POST
      },
      formInfo: {
        url: this.getUrl() + '/sysFormInfo/info',
        method: MethodTypeEnum.GET
      },
      createForm: {
        url: this.getUrl() + '/sysFormInfo/createForm',
        method: MethodTypeEnum.POST
      },
      createByTable: {
        url: this.getUrl() + '/sysFormInfo/createByTable',
        method: MethodTypeEnum.POST
      },
      /*createFormField: { // 用于form-data.ts的数据导入
        url: this.getUrl() + "/sysFormInfo/createFormField",
        method: MethodTypeEnum.POST
      },*/
      updateFormField: {
        url: this.getUrl() + '/sysFormInfo/updateFormField',
        method: MethodTypeEnum.POST
      },
      delFormField: {
        url: this.getUrl() + '/sysFormInfo/delFormField',
        method: MethodTypeEnum.DELETE
      }
    };
    this.fcFormConfigApi = {
      list: {
        url: this.getUrl() + '/sysFcFormInfo/list',
        method: MethodTypeEnum.POST
      },
      formInfo: {
        url: this.getUrl() + '/sysFcFormInfo/info',
        method: MethodTypeEnum.GET
      },
      createForm: {
        url: this.getUrl() + '/sysFcFormInfo/createOrUpdate',
        method: MethodTypeEnum.POST
      }
    };
    this.tableConfigApi = {
      list: {
        url: this.getUrl() + '/sysTableInfo/list',
        method: MethodTypeEnum.POST
      },
      info: {
        url: this.getUrl() + '/sysTableInfo/info',
        method: MethodTypeEnum.GET
      },
      create: {
        url: this.getUrl() + '/sysTableInfo/create',
        method: MethodTypeEnum.POST
      },
      createByTable: {
        url: this.getUrl() + '/sysTableInfo/createByTable',
        method: MethodTypeEnum.POST
      },
      createField: {
        // 用于table-data.ts的数据导入
        url: this.getUrl() + '/sysTableInfo/createField',
        method: MethodTypeEnum.POST
      },
      updateField: {
        url: this.getUrl() + '/sysTableInfo/updateField',
        method: MethodTypeEnum.POST
      }
    };
  }
  getUrl(): string {
    return BaseApi.getUrl(ServiceEnum.system);
  }
}
export const systemApi = new SystemApi();
